#include<bits/stdc++.h>
using namespace std;
int T,n,m,l,v;
int b[100005];
struct node{
    int d,v,a;
}a[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T--){
        int k;
        int sum=0;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++)cin>>a[i].d>>a[i].v>>a[i].a;
        for(int i=1;i<=m;i++)cin>>b[i];
        if(a[1].a>0)k=1;
        else if(a[1].a==0)k=2;
        else k=3;
        if(k==2){
            for(int i=1;i<=n;i++){
                if(a[i].v>v&&a[i].d<=b[m]){
                    sum++;
                }
            }
            cout<<sum<<" ";
            if(sum==0)cout<<m;
            else cout<<m-1;
        }else if(k==1){
            for(int i=1;i<=n;i++){
                if(a[i].v*a[i].v+2*a[i].a*b[m]>v*v&&a[i].d<=b[m])sum++;
            }
            cout<<sum<<" ";
            if(sum==0)cout<<m;
            else cout<<m-1;
        }
        cout<<"\n";
    }
    return 0;
}
